
<!-- 逆变器 -->
<template>
	<view class="inverter">
		<navBar :title="title" left-icon="back" :isBackGround="false" @onLeftIcon="onLeftIcon"></navBar>
		<!-- 选择条 -->
		<view class="control">
			<uni-segmented-control :current="current" :values="items" @clickItem="onClickItem" styleType="text"
				activeColor="#007aff"></uni-segmented-control>
		</view>
		<view class="content">
			<view v-if="current === 0">
				<detail :did="did" />
			</view>
			<view v-else-if="current === 1">
				<warn :did="did" />
			</view>
			<view v-else-if="current === 2">
				<connection :did="did" />
			</view>
			<view v-else="current === 3">
				<history :did="did" />
			</view>
		</view>
	</view>
</template>

<script>
	import navBar from '@/components/navbar/index.vue'
	import detail from './detail.vue'
	import warn from './warn.vue'
	import connection from './connection.vue'
	import history from './history.vue'
	export default {
		components: {
			navBar,
			detail,
			warn,
			connection,
			history
		},
		data() {
			return {
				items: ['详情', '报警信息', '连接信息', "历史数据"],
				current: 0,
				did: '',
				title: "",
			};
		},
		methods: {
			onClickItem(e) {
				if (this.current != e.currentIndex) {
					this.current = e.currentIndex;
				}
			},
			onLeftIcon() {
				uni.navigateBack()
			}
		},
		onLoad(params) {
			this.did = params.did || ""
			this.title = (params.title + params.sn) || ""
		}
	}
</script>

<style scoped lang="scss">
	.inverter {
		background-color: $bg-color;
		.control {
			background-color: #fff;
		}
	}
</style>